//--------------------------------------------------- // Purpose: Calculate path of cannon ball // Author: John Gauch //--------------------------------------------------- #include #include using namespace std; int main() { // Declare variables float X = 0; float Y = 0; float Vx = 0; float Vy = 0; float Ax = 0; float Ay = -9.8; // Get initial velocity of cannon ball cout << "Enter cannon ball velocity (Vx Vy): "; cin >> Vx >> Vy; // Loop calculating cannon ball location for (int second = 0; (second < 100) && (Y >= 0); second++) { // Print location cout << " t: " << second << " x: " << X << " y: " << Y << endl; // Update location X = X + Vx; Y = Y + Vy; // Update velocity Vx = Vx + Ax; Vy = Vy + Ay; } }